<include file="public/header" title="修改密码"/>
    <div class="classreturn loginsignup">
        <div class="content">
            <div class="ds-in-bl return">
                <a href="javascript:history.back(-1);"><img src="__STATIC__/images/return.png" alt="返回"></a>
            </div>
            <div class="ds-in-bl search center">
                <notempty name="$has_password">
                    <span>修改密码</span>
                <else/>
                    <span>设置密码</span>
                </notempty>
            </div>
            <!--<div class="ds-in-bl menu">
                <a href="javascript:void(0);"><img src="__STATIC__/images/class1.png" alt="菜单"></a>
            </div>-->
        </div>
    </div>
    <div class="loginsingup-input">
        <form action="" method="post" id="pwdForm">
            <div class="reset-pwd-title">修改登录密码</div>
            <if condition="!empty($user[password])">
                <div class="lsu">
                    <span class="ico ico-old-password"></span>
                    <input type="password" name="old_password" id="old_password" value=""  placeholder="旧密码">
                </div>
            </if>
            <div class="lsu">
                <span class="ico ico-password"></span>
                <input type="password" name="new_password" id="new_password" value=""  placeholder="新密码">
            </div>
            <div class="lsu">
                <span class="ico ico-password"></span>
                <input type="password" name="confirm_password" id="confirm_password" value=""  placeholder="确认新密码">
            </div>

            <div class="lsu-submit">
                <input type="button" onclick="submitverify()" id="sub" value="确认修改">
            </div>
        </form>
    </div>
<script src="__STATIC__/js/style.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
    //验证表单
    function submitverify(){
        var newpass = $.trim($('#new_password').val());
        var confirmpass = $.trim($('#confirm_password').val());
        if(newpass =='' ||  confirmpass == ''){
            showErrorMsg('密码不能为空');
            return false;
        }
        if(newpass !== confirmpass){
            showErrorMsg('两次密码不一致');
            return false;
        }
        if(newpass.length < 6 || confirmpass.length < 6){
            showErrorMsg('密码长度不能少于6位');
            return false;
        }
        $.ajax({
            url : "/index.php?m=Mobile&c=User&a=password",
            type:'post',
            dataType:'json',
            data:$('#pwdForm').serialize(),
            success:function(data){
                if(data.status==1){
                    //成功
                    layer.open({content: data.msg,time:2});
                        window.location.href=data.url;
                }else{
                    //失败
                    showErrorMsg(data.msg);
                }
            },
            error:function(){
                showErrorMsg('网络异常，请稍后再试')
            }
        })
    }
</script>
	</body>
</html>
